package com.guge.sports.controller;


import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.guge.sports.entity.Dto.Option;
import com.guge.sports.entity.Dto.RunningDetailsDataDto;
import com.guge.sports.entity.Dto.StDeptDto;
import com.guge.sports.entity.StDept;
import com.guge.sports.service.StDeptService;
import com.guge.sports.toolPackage.base.BaseController;
import com.guge.sports.utils.R;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author testjava
 * @since 2022-09-14
 */
@Api(description = "院系接口")
@RestController
@RequestMapping("/sports/st-dept")
public class StDeptController extends BaseController<StDept> {


    @Autowired
    private StDeptService stDeptService;

    @ApiOperation(value = "获取学院列表")
    @GetMapping("/getDeptNameAndDidList")
    public R getDeptNameAndDidList(){
        List<Option> options = stDeptService.getDeptNameAndDidList();
        return R.ok().data("depts",options);
    }


    @ApiOperation(value = "获取学院基础设置")
    @PostMapping("/getDeptNameAndDidList/list/{current}/{size}")
    public Object selectDeptList(@PathVariable("current") Long current , @PathVariable("size") Long size){
        Page<StDeptDto> objectPage = new Page<>(current, size);
        Page<StDeptDto> stDeptDtoPage = stDeptService.StDeptDtoList(objectPage);
        return R.ok().data("page",stDeptDtoPage);
    }


    @ApiOperation(value = "学院基础设置添加")
    @PostMapping("/StDeptDto/add")
    public Object StDeptDtoAdd(@RequestBody  StDeptDto stDeptDto){
        System.out.println(stDeptDto);
         stDeptService.StDeptDtoAdd(stDeptDto);
        return R.ok();
    }


    @ApiOperation(value = "学院基础设置修改")
    @PostMapping("/StDeptDto/update")
    public Object StDeptDtoAdd(@RequestBody StDept stDeptDto){
        stDeptService.StDeptUpdateByid(stDeptDto);
        return R.ok();
    }




    @ApiOperation(value = "学院基础设置根据id删除")
    @PostMapping("/StDeptDto/delete/{id}")
    public Object StDeptDtoDelete(@PathVariable("id") Long id){
        stDeptService.DeleteById(id);
        return R.ok();
    }


    @ApiOperation(value = "学院基础设置根据id查询")
    @PostMapping("/StDeptDto/selectById/{id}")
    public Object StDeptDtoSelectById(@PathVariable("id") Long id){
        StDeptDto stDeptDto = stDeptService.SelectById(id);
        return R.ok().data("data" , stDeptDto);
    }
}

